package cn.yjr.service.impl;

import cn.yjr.entity.Order;
import cn.yjr.mapper.storage.StorageMapper;
import cn.yjr.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class StorageServiceImpl implements StorageService {

    @Autowired
    StorageMapper storageMapper;

    @Override
    public void decreaseStorage(Order order) {
        int i = storageMapper.decreaseStorage(order);
        if (i == 0) {
            throw new RuntimeException("库存削减失败");
        }
    }
}
